#!/bin/sh

# 检查操作系统类型
OS_TYPE=$(awk -F= '/^NAME/{print $2}' /etc/os-release)

# 仅在 Ubuntu 或 CentOS 7.9 系统上运行
if [ "$OS_TYPE" = "\"Ubuntu\"" ] || [ "$OS_TYPE" = "\"CentOS Linux\"" ]; then
  # 服务列表
  SERVICES="
    avahi-daemon.service
    crond.service
    dnsmasq.service
    firewalld.service
    lvm2-monitor.service
    postfix.service
    rpcgssd.service
    rpcidmapd.service
    rpcsvcgssd.service
    wpa_supplicant.service
  "

  # 循环禁用和停止服务
  for SERVICE in $SERVICES
  do
    echo "正在禁用 $SERVICE"
    systemctl disable $SERVICE
    echo "正在停止 $SERVICE"
    systemctl stop $SERVICE
  done

  echo "所有指定服务已被禁用和停止。"
else
  echo "不支持的操作系统类型：$OS_TYPE"
  echo "仅支持 Ubuntu 和 CentOS 7.9 系统。"
  exit 1
fi
